package com.shixu.framework.plugins.qyweixin.pojo;

import java.util.Date;

public class ApiTicket {
	// 获取到的凭证
	private String ticket;
	// 刷新用token
	private String refreshTicket;
	// 凭证有效时间，单位：秒
	private int expiresIn;
	// 刷新时间
	private long updateTime;

	public long getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(long updateTime) {
		this.updateTime = updateTime;
	}

	public int getExpiresIn() {
		return expiresIn;
	}

	public void setExpiresIn(int expiresIn) {
		this.expiresIn = expiresIn;
	}

	public String getTicket() {
		return ticket;
	}

	public void setTicket(String ticket) {
		this.ticket = ticket;
	}

	public String getRefreshTicket() {
		return refreshTicket;
	}

	public void setRefreshTicket(String refreshTicket) {
		this.refreshTicket = refreshTicket;
	}

	/**
	 * 是否过期 default: true
	 * 
	 * @return true|false
	 */
	public boolean isExpired() {
		long currentTime = new Date().getTime();
		long elapsedTime = (currentTime - this.updateTime) / 1000 + 200;

		System.out.println("elapsedTime" + elapsedTime);

		return (this.expiresIn <= elapsedTime);
	}

}
